﻿using System.Linq;
using Roslyn.Compilers.Common;

namespace RoslynHelper
{
    public static class Variable
    {
        public static string GetVariableName(this ISemanticModel semanticModel, string variableName)
        {
            string variableLoop = variableName;
            int variableIndex = 1;
            while (semanticModel.LookupSymbols(0).Any(s => s.Name == variableLoop))
                variableLoop = variableName + (variableIndex++).ToString();
            return variableName;
        }
    }
}
